package com.example.demo.controller;

import com.example.demo.common.BasePageResponse;
import com.example.demo.common.ResultObject;
import com.example.demo.jooq.tables.pojos.Address;
import com.example.demo.jooq.tables.pojos.VisaCard;
import com.example.demo.model.request.VisaPageRequest;
import com.example.demo.model.request.VisaRequest;
import com.example.demo.model.response.VirtualResponse;
import com.example.demo.model.response.VisaResponse;
import com.example.demo.model.response.VpsResponse;
import com.example.demo.service.order.IVisaCardService;
import com.example.demo.service.order.IVpsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("v1/card/")
public class VisaController {
    @Autowired
    private IVisaCardService iVisaCardService;
    @GetMapping(value = "list")
    public ResultObject<BasePageResponse<VisaResponse>> queryPageCardList(VisaPageRequest visaPageRequest) {
        return iVisaCardService.queryPageCardList(visaPageRequest);
    }

    /**
     * 虚拟卡保存
     * @param visaCard 数据对象
     * @return
     */
    @PostMapping(value = "save")
    public ResultObject  saveAddress(@RequestBody VisaRequest visaCard) {
        return iVisaCardService.saveCard(visaCard);
    }


    /**
     * 查询VPS详情
     * @param cardId 主键id
     * @return
     */
    @GetMapping(value = "detail")
    public ResultObject<VisaResponse>  queryOneCard(@RequestParam("cardId") String cardId) {
        return iVisaCardService.queryCardDetail(cardId);
    }
}
